package graphic.animation;

import graphic.Assets;
import graphic.drawables.Frame;
import graphic.drawables.Sprite;

import java.util.Random;

public class FrameBuilder {
	
	public static Frame[] buildFrames(Sprite sprite, boolean debug){
		
		Frame[] tmp = new Frame[3];
		Random r = new Random();
		
			int dim = sprite.getWidth() *sprite.getHeight();
			int[] framePixels = new int[ dim ];
			for (int j = 0; j < dim; j++) {
				
				framePixels[j] = 0xFF000000| r.nextInt(12000);
			}
			tmp[1] = new Frame(1, sprite.getSpritePixels(), sprite.getWidth(), sprite.getHeight());
			tmp[0] = new Frame(0, framePixels, sprite.getWidth(), sprite.getHeight());
		
		return tmp;
	}

	
	public static Sprite[] buildFrames(int IDAnimation){
		
		AnimationFrames animationFrames = Assets.getsLoader().getAnimation(IDAnimation);
		
		String[] framePaths = animationFrames.getFramePaths();
		
		Sprite[] sprites = new Sprite[framePaths.length];
		
		for (int i = 0; i < framePaths.length; i++) {
			sprites[i] = new Sprite(framePaths[i]);
		}
		
		return sprites;
		
	}
	
}
